RTI Connext Modern C++ API: dds::sub::SampleInfo Class Reference 您所在的位置:网站首页 sample infor RTI Connext Modern C++ API: dds::sub::SampleInfo Class Reference

RTI Connext Modern C++ API: dds::sub::SampleInfo Class Reference

2024-07-01 23:42| 来源: 网络整理| 查看: 265

Information that accompanies each sample received by a DataReader

Information that accompanies each sample that is read or taken.

Interpretation of the SampleInfo

The dds::sub::SampleInfo contains information pertaining to the associated Data instance sample including:

the dds::sub::status::DataState of the Data value. The DataState provides information about:

the sample_state of the Data value (i.e., if it has already been read or not)

the view_state of the related instance (i.e., if the instance is new or not)

the instance_state of the related instance (i.e., if the instance is alive or not) dds::sub::SampleInfo::valid flag. This flag indicates whether there is data associated with the sample. Some samples do not contain data indicating only a change on the instance_state of the corresponding instance. the dds::sub::GenerationCount of the Data value. The GenerationCount provides information about: The values of disposed_generation_count and no_writers_generation_count for the related instance at the time the sample was received. These counters indicate the number of times the instance had become ALIVE (with instance_state= dds::sub::status::InstanceState::alive()) at the time the sample was received. the dds::sub::Rank of the Data value. The Rank provides information about:

The sample_rank and generation_rank of the sample within the returned sequence. These ranks provide a preview of the samples that follow within the sequence returned by the read or take operations.

The absolute_generation_rank of the sample within the dds::sub::DataReader. This rank provides a preview of what is available within the dds::sub::DataReader. The source_timestamp of the sample. This is the timestamp provided by the dds::pub::DataWriter at the time the sample was produced. Interpretation of the SampleInfo disposed_generation_count and no_writers_generation_count

For each instance, RTI Connext internally maintains two counts, the dds::sub::GenerationCount::disposed() and dds::sub::GenerationCount::no_writers(), relative to each DataReader:

The dds::sub::GenerationCount::disposed() and dds::sub::GenerationCount::no_writers() are initialized to zero when the dds::sub::DataReader first detects the presence of a never-seen-before instance. The dds::sub::GenerationCount::disposed() is incremented each time the instance_state of the corresponding instance changes from dds::sub::status::InstanceState::not_alive_disposed() to dds::sub::status::InstanceState::alive(). The dds::sub::GenerationCount::no_writers() is incremented each time the instance_state of the corresponding instance changes from dds::sub::status::InstanceState::not_alive_no_writers() to dds::sub::status::InstanceState::alive(). These 'generation counts' are reset to zero when the instance resource is reclaimed.

The dds::sub::GenerationCount::disposed() and dds::sub::GenerationCount::no_writers() available in the dds::sub::SampleInfo capture a snapshot of the corresponding counters at the time the sample was received.

Interpretation of the SampleInfo sample_rank, generation_rank and absolute_generation_rank

The dds::sub::Rank::sample() and dds::sub::Rank::generation() available in the dds::sub::SampleInfo are computed based solely on the actual samples in the ordered collection returned by read or take.

The dds::sub::Rank::sample() indicates the number of samples of the same instance that follow the current one in the collection. The dds::sub::Rank::generation() available in the dds::sub::SampleInfo indicates the difference in "generations" between the sample (S) and the Most Recent Sample of the same instance that appears in the returned Collection (MRSIC). That is, it counts the number of times the instance transitioned from not-alive to alive in the time from the reception of the S to the reception of MRSIC. These 'generation ranks' are reset to zero when the instance resource is reclaimed.

The dds::sub::Rank::generation() is computed using the formula:

generation_rank = (MRSIC.disposed_generation_count + MRSIC.no_writers_generation_count) - (S.disposed_generation_count + S.no_writers_generation_count)

The dds::sub::Rank::absolute_generation() available in the dds::sub::SampleInfo indicates the difference in "generations" between the sample (S) and the Most Recent Sample of the same instance that the middleware has received (MRS). That is, it counts the number of times the instance transitioned from not-alive to alive in the time from the reception of the S to the time when the read or take was called.

absolute_generation_rank = (MRS.disposed_generation_count + MRS.no_writers_generation_count) - (S.disposed_generation_count + S.no_writers_generation_count) Interpretation of the SampleInfo counters and ranks

These counters and ranks allow the application to distinguish samples belonging to different "generations" of the instance. Note that it is possible for an instance to transition from not-alive to alive (and back) several times before the application accesses the data by means of read or take. In this case, the returned collection may contain samples that cross generations (i.e. some samples were received before the instance became not-alive, other after the instance re-appeared again). Using the information in the dds::sub::SampleInfo, the application can anticipate what other information regarding the same instance appears in the returned collection, as well as in the infrastructure and thus make appropriate decisions.

For example, an application desiring to only consider the most current sample for each instance would only look at samples with sample_rank == 0. Similarly, an application desiring to only consider samples that correspond to the latest generation in the collection will only look at samples with generation_rank == 0. An application desiring only samples pertaining to the latest generation available will ignore samples for which absolute_generation_rank != 0. Other application-defined criteria may also be used.

See alsodds::sub::status::SampleState, dds::sub::status::InstanceState, dds::sub::status::ViewState, dds::sub::SampleInfo::valid Statechart of the instance_state and view_state of a single instance


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有